package com.chenjun.common.json;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

/**
 * 使用方式  @JsonDeserialize(using=LongDateDeserializer.class)
 * 
 * @Title LongDateDeserializer
 * @Description:
 * @author 李伟
 * @date 2015年8月24日 下午4:57:43
 */
public class LongDateDeserializer extends JsonDeserializer<Date> {

	@Override
	public Date deserialize(JsonParser arg0, DeserializationContext arg1) throws IOException, JsonProcessingException {
		Date date = null;
		try {
			String text = arg0.getText();
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			date = sf.parse(text);
		} catch (Exception e) {
		}
		return date;
	}

}
